
//
// 110101 - AH - Created.
// 110102a- AH - First visualization of a Network.
// 110102b- AH - Moved methods positionVertexAt and adjustDisplaySettings to new
//               utility class org.soekrat.gui.swing.util.JGraphUtil
// 110103 - AH - Renamed from JGraphTest.
// 120321 - AH - Removed @Override for interface method (1.5 compatible).
//

package org.soekrat.lab.swing.jgraph;

//import static org.soekrat.gui.swing.util.JGraphUtil.adjustDisplaySettings;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import org.jgrapht.ext.JGraphModelAdapter;
import org.soekrat.engine.network.Network;
import org.soekrat.engine.network.NetworkEdge;
import org.soekrat.engine.network.NetworkNode;

/**
 * <p>
 *   Testing use of JGraph library for visualizing 
 *   {@link Network}. 
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
@SuppressWarnings("serial")
public final class NetworkJGraphTest extends JFrame
{
  private static final Dimension DEFAULT_SIZE=new Dimension(530, 320);
  
  private final JGraphModelAdapter<NetworkNode, NetworkEdge> m_adapter=null;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  private NetworkJGraphTest()
  {
    /*
    Container c=getContentPane();
    c.setLayout(new BorderLayout());
    
    Network network=new Network();
    NetworkNode node0=network.createNode("n0");
    NetworkNode node1=network.createNode("n1");
    network.link(node0, node1);
    network.link(node1, node0);
    
    Graph<NetworkNode, NetworkEdge> g=network.getGraph();
    m_adapter=new JGraphModelAdapter<NetworkNode, NetworkEdge>(g);
    
    JGraph jgraph=new JGraph(m_adapter);
    
    positionVertexAt(m_adapter, node0, 130, 40);
    positionVertexAt(m_adapter, node1, 60, 200);

    adjustDisplaySettings(jgraph, DEFAULT_SIZE);
    c.add(new JScrollPane(jgraph), BorderLayout.CENTER);
    setSize(DEFAULT_SIZE);

    pack();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    */
  }
  
  @SuppressWarnings("unused")
  private void layout(JGraphModelAdapter<NetworkNode, NetworkEdge> g)
  {
    if (g==null)
    {
      throw new NullPointerException("g");
    }
    
    // TODO
    
  }
   
  /**
   * <p>
   *   Run test.
   * </p>
   * @param args Command line arguments, not used.
   */
  public static void main(String[] args) 
  {
    SwingUtilities.invokeLater
    (
      new Runnable() 
      {
        public void run() 
        {
          new NetworkJGraphTest().setVisible(true); 
        }
      }
    );
  }
  
}
